<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>管理员界面</title>
	<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.4.5/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.4.5/themes/icon.css">
	<script type="text/javascript" src="js/jquery-easyui-1.4.5/jquery.min.js"></script>
	<script type="text/javascript" src="js/jquery-easyui-1.4.5/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="js/jquery-easyui-1.4.5/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript">
//删除用户	
function remove(){
		var row=$('#dg').datagrid('getSelected');
		console.log(row.uid);
		$.ajax({
			url:"MUser?method=removeU",
			type:"post",
			data:{
				uid:row.uid
			},
			success:function(d){
				if(d=="1"){
					$.messager.show({
						title:'提示',
						width:300,
						height:200,
						msg:'['+row.uid+']'+row.nickname+'删除成功',
						timeout:3000,
						showType:'slide'
					});
					$('#dg').datagrid('reload'); 
				}
			}
		})
	}
//找回用户	
function callback(){
		var row=$('#dg2').datagrid('getSelected');
		console.log(row.uid);
		$.ajax({
			url:"MUser?method=callBackU",
			type:"post",
			data:{
				uid:row.uid
			},
			success:function(d){
				if(d=="1"){
					$.messager.show({
						title:'提示',
						width:300,
						height:200,
						msg:'['+row.uid+']'+row.nickname+'恢复成功',
						timeout:3000,
						showType:'slide'
					});
					$('#dg').datagrid('reload'); 
					$('#win').window('close');
				}
			}
		})
	}
//修改用户
	function submitD(){
		var row=$('#dg').datagrid('getSelected');
		$('#f2').form('submit', {
		    url:"MUser?method=modifyU",
		    onSubmit: function(){
				return true;
		    },
		    success:function(d){
		    	if(d=="1"){
//		    	var row=$('#dg').datagrid('getSelected');
		    	$.messager.show({
					title:'提示',
					width:300,
					height:200,
					msg:'['+row.uid+']'+row.nickname+'修改成功',
					timeout:3000,
					showType:'slide'
				});
				$('#dg').datagrid('reload'); 
				clearD();
				$('#win2').window('close');
		    }
		    	}
		});
	}
function clearD(){
	$('#f2').form('clear');
	$('#win2').window('close');
}	
function clearS(){
	$('#su').textbox('setValue',"");
	$('#win').window('close');
}	

//初始化
		$(function(){
			$('#win').window('close');
			$('#win2').window('close');
			$('#dg').datagrid({
				singleSelect:true,
			    url:'MUser?method=getU',
			    columns:[[
					{field:'uid',title:'id',width:60},
					{field:'pwd',title:'密码',width:100},
					{field:'nickname',title:'昵称',width:100},
					{field:'score',title:'积分',width:100},
					{field:'area',title:'区域',width:50},
					{field:'count',title:'违规次数',width:100},
					{field:'lastdate',title:'最后登录时间',width:150}
					
			    ]],
		    toolbar: [{
				iconCls: 'icon-edit',
				handler: function(){
					var row=$('#dg').datagrid('getSelected');
					if(row!=null){
						$('#uid').textbox('setValue',row.uid);
						$('#score').textbox('setValue',row.score);
						$('#win2').window('open');
						}
					}
			},'-',{
				iconCls: 'icon-remove',
				handler: function(){remove();}
			},'-',{
				iconCls: 'icon-search',
				handler: function(){
					$('#win').window('open');
					$('#dg2').datagrid({
						singleSelect:true,
					    url:'MUser?method=getdeU',
					    columns:[[
							{field:'uid',title:'id',width:60},
							{field:'pwd',title:'密码',width:100},
							{field:'nickname',title:'昵称',width:100},
							{field:'score',title:'积分',width:100},
							{field:'area',title:'区域',width:50},
							{field:'count',title:'违规次数',width:100},
							{field:'lastdate',title:'最后登录时间',width:150}	
					    ]]
					})
					
					
				}
			}]
		});
//查询用户信息			
			$("#btn").click(function(){
				$('#dg').datagrid('load',{
								search:$('#search').textbox('getValue')
							});
	});
//清空查询信息	
			$("#btn2").click(function(){
				$('#search').textbox('setValue',"");
				$('#dg').datagrid('load',{
								search:""
							});
	});
//查询被删除用户信息			
$("#btn3").click(function(){
	$('#dg2').datagrid('load',{
					search:$('#su').textbox('getValue')
				});	
		})

});
	</script>
</head>
<body>
	<input class="easyui-textbox" type="text" id="search" style="width:120px"></input>
	<button id="btn">搜索</button>&nbsp;<button id="btn2">刷新</button>
	<table id="dg" width="900" data-options="striped:true,pagination:true"></table>
<!-- 修改用户信息 -->
	<div id="win2" class="easyui-window" title="修改用户" style="width:400px;height:300px"
	    data-options="iconCls:'icon-save',modal:true">
	 <form id="f2" method="post">
	    	<table cellpadding="5">
	    		<tr>
	    			<td>用户id:</td>
	    			<td><input class="easyui-textbox" type="text" name="uid" id="uid" data-options="required:true,readonly:true"></input></td>
	    		</tr>
	    		<tr>
	    			<td>用户积分:</td>
	    			<td><input class="easyui-textbox" type="text" id="score" name="score" data-options="required:true"></input></td>
	    		</tr>

	    	</table>
	    </form>
	      <div style="text-align:center;padding:5px">
	    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitD()">确定</a>
	    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearD()">取消</a>
	    </div>
	    </div>
<!-- 查询删除用户 -->
	<div id="win" class="easyui-window" style="width:710px;height:350px"
	    data-options="iconCls:'icon-save',modal:true">
	用户id/用户名:<input class="easyui-textbox" type="text" id="su"></input><button id="btn3">搜索</button>
	    	
	    		<table id="dg2" width="650" data-options="striped:true,pagination:true"></table>

	      <div style="text-align:center;padding:5px">
	    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="callback()">找回</a>
	    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearS()">取消</a>
	    </div>
	    </div>	    
</body>
</html>